package fan_video.controller;

import fan_video.model.Comments;
import fan_video.service.Interfaces.Comment_Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Comment_Controller {
    @Autowired
    private Comment_Service comment_service;

    @RequestMapping("/comment")
    //暂时未使用此接口
    public String comment(int[] fvid){

        return "finished";
    }

    @RequestMapping("/comment/first")
    public String comment_first(int fvid,int PageSize,int PageNum){
        //获取一级评论，传入fvid和当前评论页数和每页评论大小会返回当前页对应的评论，总共有几页，总共有几条评论
        return comment_service.commentFirst(fvid,PageSize,PageNum);
    }

    @RequestMapping("/comment/second")
    public String comment_second(int comment_id,int PageSize,int PageNum){
        //获取二级评论,与一级接口的区别是传入fvid改为传入一级评论id
        return comment_service.commentSecond(comment_id,PageSize,PageNum);
    }


    @RequestMapping("/insertComment")
    public void insertComment(Comments comments, @RequestHeader("token") String token) throws Exception {
        //传入comment_id或者fvid加上用户token即可增加评论
        comment_service.insertComment(comments,token);
    }

    @RequestMapping("/userComment")
    public String userComment(@RequestHeader("token") String token) throws Exception {
        //在用户中心显示TOP3最新评论的接口
        return comment_service.userComment(token);
    }



}
